<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    
<!DOCTYPE html>
<html>
<head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="properties.text" />

<%@ include file="/SharedPages/SharedPage.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="/jt-hr-WEB/css/styles.css">
<script type="text/javascript" src="validateInterview.js"></script>
<script type="text/javascript">
    var datefield=document.createElement("input")
    datefield.setAttribute("type", "date")
    if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
        document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n')
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n')
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n')
    }
</script>
 
<script>
if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
    jQuery(function($){ //on document.ready
        $('#dateInterview').datepicker();
    })
}
</script>
<title><fmt:message key="candidate" /></title>
</head>
<body>
<div id="header">
	    <div id="img">
        	<img class="center" src="/jt-hr-WEB/img/msg_header.jpg" height="100px" width="500px"/>    
    		<jsp:include page="/SharedPages/SharedPage.jsp"></jsp:include>
    	</div>
    </div>
<jsp:useBean id="userInterviewList" class="java.util.Vector<User>" scope="session"/>
<jsp:useBean id="candidateInterviews" class="java.util.Vector<Interview>" scope="session"/>
<jsp:useBean id="newUserList" class="java.util.Vector<User>" scope="session"/>
<%@ page import="entityJPA.*" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.*" %>

<div class="content">
	<h3 align="center"><fmt:message key="interviews" /></h3>
<div id="formul">
<form action="interviewServlet" method="POST">

<table align="center" style="width:50%">
	<tr>
	<td style="display:none">
		<input type="text" value="" name="deletedUserId" id="deletedUserId" >
	</td>
	<td>
			<fmt:message key="user" /> :
	</td>
			<td><select name="userInterview" id="userInterview">
			
				<c:forEach items="${userInterviewList}" var="userInt">
           				 <option value="${userInt.idUser}">${userInt.firstName} ${userInt.lastName}</option>
       				 </c:forEach>
	     				 
       				 
					  </select>
	 		<input type="submit" value=<fmt:message key="insertUser" />  name="addUserInterview" > 
			</td>
		
	 </tr>
	 <tr>
	 <td>
	 </td>
	 <td>
	 	<table>
	 		<%
 		 for (User user: newUserList) {
        %>
        <tr onclick="getDeletedUser(this)"> 
        	<td style="display:none"> <%=user.getIdUser()%> </td>
        	<td><%= user.getFirstName()+" "+ user.getLastName() %> </td>
        	<td><input type="submit" id="deleteUser" name="deleteUser" value=<fmt:message key="remove" />  > </td>
        </tr>
        <%
	}
%>
	 	</table>
	 </td>

	 </tr>
	<tr>
	<td>
			<fmt:message key="date" /> :
			</td>
			<td> <input type="date" name="dateInterview" id="dateInterview" value="<%=request.getParameter("dateInterview")!=null?request.getParameter("dateInterview"):""%>" >
	</td>
	</tr>
	<tr>
	<td>
			<input type="submit" value=<fmt:message key="insertInterview" />  name="addInterview" id="addInterview" onclick="return validateInterviewFields();">
	</td>
	</tr>
	<tr>
	<td>
			<a href="http://localhost:8080/jt-hr-WEB/candidate/displayCandidate" id="backbutton"><fmt:message key="back" /></a>
	</td>
	</tr>			
</table>	
</form>
</div>

<table border=2 align="center" style="width:50%" class="infoTable">
<tr>
	<th><fmt:message key="date" /></th>
	<th><fmt:message key="user" /></th>
</tr>
<%
  for ( Interview i: candidateInterviews) {
        %>
        <tr> 
        	<%
         		DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
         	 	Date date = i.getDate();
         		String datestring = dateFormat.format(date);
         	%>
        	<td><%= datestring %></td>
        	<td><%= i.usersToString() %></td>
        </tr>
        <%
	}
%>
</table>
		

</div>
<script>
	var lang='<c:out value="${language}"/>';
	select=document.getElementById("language");
	if(lang=="de_DE"||lang=="de"){
		select.options[1].defaultSelected=true;
	}
	else if(lang=="ro_RO"||lang=="ro"){
		select.options[2].defaultSelected=true;
	}
	else {
		select.options[0].defaultSelected=true;
	}

	
</script>
<td><input type="hidden" name=<fmt:message key="emptyinterview" /> id="emptyinterview"></td>
</body>
</html>